$(function(){
    $('#message_diagrid').datagrid({
        url:'/member/list',
       /* data: [
            {member_name:'刘先生', member_number:'1004',tel:'15112308250',grade:'普通会员',balance:'30000'},
            {member_name:'朱先生', member_number:'1005',tel:'15016723090',grade:'高级会员',balance:'5000'}
        ],*/
        columns:[[
            {field:'memberName',title:'会员姓名',width:100},
            {field:'memberNumber',title:'会员卡号',width:100},
            {field:'tel',title:'电话号码',width:100},
            {field:'grade',title:'会员等级',width:100,formatter: function(value,row,index){
                return value?value.name:"";
            }
            },
            {field:'balance',title:'会员余额',width:100}

        ]],
        fitColumns:true,
        rownumbers:true,
        singleSelect:true,
        closed:true,
        onClickRow:function(index, row){
            $("#member_name").textbox("setValue",row.memberName)
            $("#tel").textbox("setValue",row.tel)
        }

    });
})
function choice() {

    $('#message_diagrid').datagrid({
       closed:false
    });
   // $("#message_diagrid").show();
}
function checkMessage() {

    $("#checkMessage_dialog").dialog({
        title: '选择模板短信信息',
        width: 500,
        height: 600,
        closed: false
    })
    $("#checkMessage_dialog").dialog("center")
    $("#message").datagrid({
        width: 500,
        height: 600,
        singleSelect:true,
        fitColumns:true,
        url:'/message/queryCheckMessage',
       /* data: [
            {classify:'刘先生',content:'朱先生'}
        ],*/
        columns:[[
            {field:'classify',title:'信息分类',width:250},
            {field:'content',title:'信息内容',width:250}

        ]],
        onClickRow:function(index, row){

            $("#content").text(row.content)

        }
    })
}

function historicalInformation(){
    $("#historical_dialog").dialog("open");
}

$(function(){
    $("#historical_dialog").dialog({
        title: '会员信息历史记录',
        width: 500,
        height: 600,
        closed: true
    })

    $("#historical_dialog").dialog("center");
    $("#historicalInformation").datagrid({
        width: 500,
        height: 600,
        singleSelect:true,
        fitColumns:true,
        url:"/message/list",
        columns:[[
            {field:'memberName',title:'会员名字',width:250},
            {field:'tel',title:'会员电话',width:250},
            {field:'content',title:'信息内容',width:250},
            {field:'sendDate',title:'发送时间',width:250}

        ]],

    })

    /*$("#tel").val(row.member_name);
    $("#tel").val(row.tel);*/

})
function send() {
    $.messager.alert('温馨提示','发送成功');
}
function query() {
    //首先要获取keyword
    var kw =  $("#keyword").textbox("getValue")
    //刷新页面把数据传入到后台
    $("#message_diagrid").datagrid("load",{
        keyword:kw
    })
}